# $Id: CMakeLists.txt 372 2011-01-12 16:58:16Z diazdiego86 $
cmake_minimum_required(VERSION 2.8)

set( sources_client src/rnaffe_application_client.cpp )

set( sources_server src/rnaffe_application_server.cpp )

set( sources_common src/rnaffe_node.cpp )

set( sources_prune saarna/rnaffe_prune_policy.h)

set( main_client src/main_client.cpp)
set( main_server src/main_server.cpp)

# gdb3 support
IF(CMAKE_BUILD_TYPE MATCHES Debug)
    message ("Compiling with -ggdb3")
    add_definitions( -ggdb3 )
endif (CMAKE_BUILD_TYPE MATCHES Debug)

add_executable( saarna_client ${sources_prune} ${sources_client} ${sources_common} ${main_client} )
add_executable( saarna_server ${sources_prune} ${sources_server} ${sources_common} ${main_server} )

# finding out GETOPT
find_library ( LIB_GETOPT 
               getopt_pp
               /usr/lib
               REQUIRED
             )

option (select_avs_randomly "Random antivirals selection." OFF)
if ( select_avs_randomly )
    message ( STATUS "Compiling saarna with random antivirals selection." )
	add_definitions (-DSELECT_AVS_RANDOMLY)
endif ( select_avs_randomly )

option (calculate_rnaffe "Fideo will be used to calculate the folding free energy." OFF)
if (calculate_rnaffe )
    message ( STATUS "Compiling saarna: fideo will be used to calculate the sequence folding free energy." )
	add_definitions (-DCALCULATE_RNAFFE)
endif ( calculate_rnaffe )

if ( LIB_GETOPT )
    set ( GETOPT_LIBRARY getopt_pp )
else ( LIB_GETOPT )
    message ( FATAL_ERROR "Install GetOpt_pp: getoptpp.googlecode.com" )
endif ( LIB_GETOPT )

# finding out RECABS
find_library ( LIB_RECABS
    NAMES
        recabs_client recabs_server

        /usr/local/lib
             )
if ( LIB_RECABS )
    set ( RECABS_CLIENT recabs_client )
    set ( RECABS_SERVER recabs_server )
else ( LIB_RECABS )
    message ( FATAL_ERROR "Install RecAbs: fud.googlecode.com" )
endif ( LIB_RECABS )

# finding out ANTIVIRALS
find_library ( LIB_ANTIVIRALS lav /usr/local/lib )
if ( LIB_ANTIVIRALS )
    set ( ANTIVIRALS_LIBRARY lav )
else ( LIB_ANTIVIRALS )
    message ( FATAL_ERROR "Install lav: lav.googlecode.com" )
endif ( LIB_ANTIVIRALS )

#finding out Fideo
find_library ( LIB_FIDEO fideo /usr/local/lib )
if ( LIB_FIDEO )
    set ( FIDEO_LIBRARY fideo )
else ( LIB_FIDEO )
    message ( FATAL_ERROR "Install Lib Fideo: fideo.googlecode.com" )
endif ( LIB_FIDEO )


set ( EXTRA_LIBS biopp fx-parser )
target_link_libraries( saarna_client ${RECABS_CLIENT} ${GETOPT_LIBRARY} ${ANTIVIRALS_LIBRARY} ${FIDEO_LIBRARY} ${EXTRA_LIBS})
target_link_libraries( saarna_server ${RECABS_SERVER} ${ANTIVIRALS_LIBRARY} ${FIDEO_LIBRARY} ${EXTRA_LIBS})

